﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.BusinessLogic.Utils;

namespace uREST.Core.Services
{
    public class ServiceFactory
    {
        public static readonly List<IuRESTService> Services = new List<IuRESTService>();

        static ServiceFactory()
        {
            RegisterServices();
        }

        private static void RegisterServices()
        {
            var types = TypeFinder.FindClassesOfType<IuRESTService>(true);
            foreach (var t in types)
            {
                var typeInstance = Activator.CreateInstance(t) as IuRESTService;
                if (typeInstance != null)
                {
                    Services.Add(typeInstance);
                }
            }
        }
    }
}
